package com.doujiang.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.doujiang.domain.Comment;
import com.doujiang.domain.dto.HotCommentDTO;
import com.doujiang.mapper.CommentMapper;
import com.doujiang.service.ICommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 评论管理Service业务层处理
 * 
 * @author 王伟舰
 * @date 2025-07-19
 */
@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements ICommentService
{
    @Autowired
    private CommentMapper commentMapper;

    @Override
    public List<Comment> getCommentsByUserId(Long userId) {
        QueryWrapper<Comment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId);
        queryWrapper.orderByDesc("created_at");
        return this.list(queryWrapper);
    }





    @Override
    public List<HotCommentDTO> getHotComments(Integer limit) {
        return commentMapper.getHotComments(limit);
    }
}
